<template>
	<om-page :title="pageTitle" class="om-font-size">
		<view class="margin-top-xs">
			<view class="content">
				<uni-list>
					<uni-list-item v-for="item in dataList" @click="itemtap(item)" :extraText="item.planFlagName" :note="item.startDate">
						<view>{{ item.customerName }}</view>
					</uni-list-item>
				</uni-list>
			</view>
		</view>
	</om-page>
</template>

<script>
	export default {
		data() {
			return {
				pageTitle: '选择数据',
				key: '',
				url: '',
				subDataArr: [],
				dataList: [],
			};
		},
		methods: {
			getDataList(){
				let _that = this;
				uni.getStorage({
					key: _that.key,
					success: function(res) {
						let obj = {};
						let item = res.data;
						for(let i=0; i<_that.subDataArr.length; i++){
							obj[Object.keys(_that.subDataArr[i])[0]] = item[Object.values(_that.subDataArr[i])[0]]
						}
						_that.om.request(_that.url, obj).then(sres => {
							if(sres.succeed){
								_that.dataList = sres.value
							}
						})
					},
				})
				
			},
			itemtap(item){
				uni.setStorage({
					key:  this.key,
					data: item
				})
				uni.navigateBack({
					delta: 2
				});
			}
		},
		onLoad(e) {
			this.key = e.key
			this.url = e.url
			this.subDataArr = JSON.parse(e.subDataArr)
			this.getDataList()
		},
	};
</script>

<style lang="scss" scoped>
	.content {
		.row{
			display: flex;
			flex-direction: row;
			align-items: center;
			.icon{
				width: 30px;
				height: 30px;
				border-radius: 6px;
				margin-right: 13px;
			}
			.text{
				font-size: 13px;
			}
		}
	}
</style>
                                                